package com.iglooit.components.gui
{
	import spark.components.CheckBox;

	public class XMLCheckBox extends CheckBox implements IXMLComponent
	{
		protected var _xml:XML;
		protected var _nodeName:String;
		protected var _nodeValue:String
		protected var _attributes:Object;

		public function XMLCheckBox()
		{
			super();
			this._xml=new XML();
		}

		public function get xml():XML
		{
			return this._xml;
		}

		public function set xml(value:XML):void
		{
			this._xml=value;
			this.selected=Convert.stringToBoolean(value);
		}

		public function set attributes(value:Object):void
		{
			this._attributes=value;
		}

		public function submit():void
		{
			var checkXML:XML=<{this._nodeName}>
					{this._nodeValue != null ? this._nodeValue : (this.selected && this.enabled)}
				</{this._nodeName}>;
			for (var key:String in this._attributes)
			{
				checkXML.@[key]=this._attributes[key];
			}
			this._xml=checkXML;
		}

		public function set nodeValue(value:String):void
		{
			this._nodeValue=value;
		}

		public function set nodeName(value:String):void
		{
			this._nodeName=value;
		}
	}
}